//----------------------------------------------------------------------------------------------------------------------
// Copyright (c) 2012 James Whitworth
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the 'Software'), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
//----------------------------------------------------------------------------------------------------------------------
#include "gmock/gmock.h"
#include "sqbind/sqbBind.h"
#include "../fixtures/SquirrelFixture.h"
#include "../mocks/autogen/MockFunction6.h"
//----------------------------------------------------------------------------------------------------------------------

//----------------------------------------------------------------------------------------------------------------------
// THIS FILE IS AUTO GENERATED DO NOT EDIT.
//----------------------------------------------------------------------------------------------------------------------

namespace autogen
{
//----------------------------------------------------------------------------------------------------------------------
typedef SquirrelFixture BindFunctionTest;

//----------------------------------------------------------------------------------------------------------------------
typedef SquirrelFixture BindClassFunctionTest;

//----------------------------------------------------------------------------------------------------------------------
typedef SquirrelFixture BindSingletonFunctionTest;

//----------------------------------------------------------------------------------------------------------------------
// Test6ParametersReturnVoid
//----------------------------------------------------------------------------------------------------------------------
TEST_F(BindFunctionTest, Test6ParametersReturnVoid)
{
  ::testing::StrictMock<MockFunction6> mock;
  MockFunction6::m_instance = &mock;

  sq_pushroottable(m_vm);
  sqb::Bind::BindClass<BoundClass, sqb::NoBaseClass>(m_vm, -1, _SC("BoundClass"));
  sqb::Bind::BindClass<OtherBoundClass, sqb::NoBaseClass>(m_vm, -1, _SC("OtherBoundClass"));
  sq_poptop(m_vm);

  OtherBoundClass invalidParameter;
  BoundClass parameter0(0);
  BoundClass parameter1(1);
  BoundClass parameter2(2);
  BoundClass parameter3(3);
  BoundClass parameter4(4);
  BoundClass parameter5(5);

  EXPECT_CALL(mock, ClassVoidFunction6(parameter0, parameter1, parameter2, parameter3, parameter4, parameter5))
    .Times(2);

  // bind the objects required for calling the function
  //
  sq_pushroottable(m_vm);

  EXPECT_TRUE(sqb::Bind::BindFunction(m_vm, -1, &MockFunction6::VoidFunction6, _SC("VoidFunction6")));

  sq_pushstring(m_vm, _SC("Mock"), -1);
  EXPECT_SQ_SUCCEEDED(m_vm, sq_newclass(m_vm, SQFalse));
  EXPECT_TRUE(sqb::Bind::BindFunction(m_vm, 3, &MockFunction6::VoidFunction6, _SC("VoidFunction6")));
  EXPECT_SQ_SUCCEEDED(m_vm, sq_rawset(m_vm, -3));

  EXPECT_TRUE(sqb::Bind::BindVariable(m_vm, -1, &invalidParameter, _SC("invalidParameter")));
  EXPECT_TRUE(sqb::Bind::BindVariable(m_vm, -1, &parameter0, _SC("parameter0")));
  EXPECT_TRUE(sqb::Bind::BindVariable(m_vm, -1, &parameter1, _SC("parameter1")));
  EXPECT_TRUE(sqb::Bind::BindVariable(m_vm, -1, &parameter2, _SC("parameter2")));
  EXPECT_TRUE(sqb::Bind::BindVariable(m_vm, -1, &parameter3, _SC("parameter3")));
  EXPECT_TRUE(sqb::Bind::BindVariable(m_vm, -1, &parameter4, _SC("parameter4")));
  EXPECT_TRUE(sqb::Bind::BindVariable(m_vm, -1, &parameter5, _SC("parameter5")));
  sq_poptop(m_vm);

  CompileAndSucceedCall("VoidFunction6(parameter0, parameter1, parameter2, parameter3, parameter4, parameter5)");
  CompileAndSucceedCall("Mock.VoidFunction6(parameter0, parameter1, parameter2, parameter3, parameter4, parameter5)");

  CompileAndFailCall("VoidFunction6(invalidParameter, parameter1, parameter2, parameter3, parameter4, parameter5)");
  CheckErrorString("parameter 1 has an invalid type 'OtherBoundClass' ; expected: 'BoundClass'");

  CompileAndFailCall("VoidFunction6(parameter0, invalidParameter, parameter2, parameter3, parameter4, parameter5)");
  CheckErrorString("parameter 2 has an invalid type 'OtherBoundClass' ; expected: 'BoundClass'");

  CompileAndFailCall("VoidFunction6(parameter0, parameter1, invalidParameter, parameter3, parameter4, parameter5)");
  CheckErrorString("parameter 3 has an invalid type 'OtherBoundClass' ; expected: 'BoundClass'");

  CompileAndFailCall("VoidFunction6(parameter0, parameter1, parameter2, invalidParameter, parameter4, parameter5)");
  CheckErrorString("parameter 4 has an invalid type 'OtherBoundClass' ; expected: 'BoundClass'");

  CompileAndFailCall("VoidFunction6(parameter0, parameter1, parameter2, parameter3, invalidParameter, parameter5)");
  CheckErrorString("parameter 5 has an invalid type 'OtherBoundClass' ; expected: 'BoundClass'");

  CompileAndFailCall("VoidFunction6(parameter0, parameter1, parameter2, parameter3, parameter4, invalidParameter)");
  CheckErrorString("parameter 6 has an invalid type 'OtherBoundClass' ; expected: 'BoundClass'");
}

//----------------------------------------------------------------------------------------------------------------------
// Test6ParametersReturnVoid
//----------------------------------------------------------------------------------------------------------------------
TEST_F(BindClassFunctionTest, Test6ParametersReturnVoid)
{
  ::testing::StrictMock<MockFunction6> mock;
  MockFunction6::m_instance = &mock;

  sq_pushroottable(m_vm);
  sqb::Bind::BindClass<BoundClass, sqb::NoBaseClass>(m_vm, -1, _SC("BoundClass"));
  sqb::Bind::BindClass<OtherBoundClass, sqb::NoBaseClass>(m_vm, -1, _SC("OtherBoundClass"));
  sq_poptop(m_vm);

  OtherBoundClass invalidParameter;
  BoundClass parameter0(0);
  BoundClass parameter1(1);
  BoundClass parameter2(2);
  BoundClass parameter3(3);
  BoundClass parameter4(4);
  BoundClass parameter5(5);

  EXPECT_CALL(mock, ClassVoidFunction6(parameter0, parameter1, parameter2, parameter3, parameter4, parameter5))
    .Times(1);
  EXPECT_CALL(mock, ConstClassVoidFunction6(parameter0, parameter1, parameter2, parameter3, parameter4, parameter5))
    .Times(1);

  // bind the objects required for calling the function
  //
  sq_pushroottable(m_vm);

  // bind the mock class
  //
  EXPECT_SQ_SUCCEEDED(m_vm, sq_newclass(m_vm, SQFalse));
  EXPECT_SQ_SUCCEEDED(m_vm, sq_settypetag(m_vm, -1, sqb::ClassTypeTag<MockFunction6>::Get()));
  HSQOBJECT class_object;
  sq_getstackobj(m_vm, -1, &class_object);
  sqb::ClassTypeTag<MockFunction6>::Get()->SetClassObject(m_vm, class_object);
  EXPECT_TRUE(sqb::Bind::BindClassFunction<MockFunction6>(m_vm, -1, &MockFunction6::ClassVoidFunction6, _SC("ClassVoidFunction6")));
  EXPECT_TRUE(sqb::Bind::BindClassFunction<MockFunction6>(m_vm, 2, &MockFunction6::ConstClassVoidFunction6, _SC("ConstClassVoidFunction6")));
  sq_poptop(m_vm);

  EXPECT_TRUE(sqb::Bind::BindVariable(m_vm, -1, static_cast<MockFunction6 *>(&mock), _SC("mock")));

  EXPECT_TRUE(sqb::Bind::BindVariable(m_vm, -1, &invalidParameter, _SC("invalidParameter")));
  EXPECT_TRUE(sqb::Bind::BindVariable(m_vm, -1, &parameter0, _SC("parameter0")));
  EXPECT_TRUE(sqb::Bind::BindVariable(m_vm, -1, &parameter1, _SC("parameter1")));
  EXPECT_TRUE(sqb::Bind::BindVariable(m_vm, -1, &parameter2, _SC("parameter2")));
  EXPECT_TRUE(sqb::Bind::BindVariable(m_vm, -1, &parameter3, _SC("parameter3")));
  EXPECT_TRUE(sqb::Bind::BindVariable(m_vm, -1, &parameter4, _SC("parameter4")));
  EXPECT_TRUE(sqb::Bind::BindVariable(m_vm, -1, &parameter5, _SC("parameter5")));
  sq_poptop(m_vm);

  CompileAndSucceedCall("mock.ClassVoidFunction6(parameter0, parameter1, parameter2, parameter3, parameter4, parameter5)");
  CompileAndSucceedCall("mock.ConstClassVoidFunction6(parameter0, parameter1, parameter2, parameter3, parameter4, parameter5)");

  CompileAndFailCall("mock.ClassVoidFunction6(invalidParameter, parameter1, parameter2, parameter3, parameter4, parameter5)");
  CheckErrorString("parameter 1 has an invalid type 'OtherBoundClass' ; expected: 'BoundClass'");
  CompileAndFailCall("mock.ConstClassVoidFunction6(invalidParameter, parameter1, parameter2, parameter3, parameter4, parameter5)");
  CheckErrorString("parameter 1 has an invalid type 'OtherBoundClass' ; expected: 'BoundClass'");

  CompileAndFailCall("mock.ClassVoidFunction6(parameter0, invalidParameter, parameter2, parameter3, parameter4, parameter5)");
  CheckErrorString("parameter 2 has an invalid type 'OtherBoundClass' ; expected: 'BoundClass'");
  CompileAndFailCall("mock.ConstClassVoidFunction6(parameter0, invalidParameter, parameter2, parameter3, parameter4, parameter5)");
  CheckErrorString("parameter 2 has an invalid type 'OtherBoundClass' ; expected: 'BoundClass'");

  CompileAndFailCall("mock.ClassVoidFunction6(parameter0, parameter1, invalidParameter, parameter3, parameter4, parameter5)");
  CheckErrorString("parameter 3 has an invalid type 'OtherBoundClass' ; expected: 'BoundClass'");
  CompileAndFailCall("mock.ConstClassVoidFunction6(parameter0, parameter1, invalidParameter, parameter3, parameter4, parameter5)");
  CheckErrorString("parameter 3 has an invalid type 'OtherBoundClass' ; expected: 'BoundClass'");

  CompileAndFailCall("mock.ClassVoidFunction6(parameter0, parameter1, parameter2, invalidParameter, parameter4, parameter5)");
  CheckErrorString("parameter 4 has an invalid type 'OtherBoundClass' ; expected: 'BoundClass'");
  CompileAndFailCall("mock.ConstClassVoidFunction6(parameter0, parameter1, parameter2, invalidParameter, parameter4, parameter5)");
  CheckErrorString("parameter 4 has an invalid type 'OtherBoundClass' ; expected: 'BoundClass'");

  CompileAndFailCall("mock.ClassVoidFunction6(parameter0, parameter1, parameter2, parameter3, invalidParameter, parameter5)");
  CheckErrorString("parameter 5 has an invalid type 'OtherBoundClass' ; expected: 'BoundClass'");
  CompileAndFailCall("mock.ConstClassVoidFunction6(parameter0, parameter1, parameter2, parameter3, invalidParameter, parameter5)");
  CheckErrorString("parameter 5 has an invalid type 'OtherBoundClass' ; expected: 'BoundClass'");

  CompileAndFailCall("mock.ClassVoidFunction6(parameter0, parameter1, parameter2, parameter3, parameter4, invalidParameter)");
  CheckErrorString("parameter 6 has an invalid type 'OtherBoundClass' ; expected: 'BoundClass'");
  CompileAndFailCall("mock.ConstClassVoidFunction6(parameter0, parameter1, parameter2, parameter3, parameter4, invalidParameter)");
  CheckErrorString("parameter 6 has an invalid type 'OtherBoundClass' ; expected: 'BoundClass'");
}

//----------------------------------------------------------------------------------------------------------------------
// Test6ParametersReturnVoid
//----------------------------------------------------------------------------------------------------------------------
TEST_F(BindSingletonFunctionTest, Test6ParametersReturnVoid)
{
  ::testing::StrictMock<MockFunction6> mock;
  MockFunction6::m_instance = &mock;

  sq_pushroottable(m_vm);
  sqb::Bind::BindClass<BoundClass, sqb::NoBaseClass>(m_vm, -1, _SC("BoundClass"));
  sqb::Bind::BindClass<OtherBoundClass, sqb::NoBaseClass>(m_vm, -1, _SC("OtherBoundClass"));
  sq_poptop(m_vm);

  OtherBoundClass invalidParameter;
  BoundClass parameter0(0);
  BoundClass parameter1(1);
  BoundClass parameter2(2);
  BoundClass parameter3(3);
  BoundClass parameter4(4);
  BoundClass parameter5(5);

  EXPECT_CALL(mock, ClassVoidFunction6(parameter0, parameter1, parameter2, parameter3, parameter4, parameter5))
    .Times(1);
  EXPECT_CALL(mock, ConstClassVoidFunction6(parameter0, parameter1, parameter2, parameter3, parameter4, parameter5))
    .Times(1);

  // bind the objects required for calling the function
  //
  sq_pushroottable(m_vm);

  // bind the mock class
  //
  sq_pushstring(m_vm, _SC("Mock"), -1);
  EXPECT_SQ_SUCCEEDED(m_vm, sq_newclass(m_vm, SQFalse));
  EXPECT_TRUE(sqb::Bind::BindSingletonFunction<MockFunction6>(m_vm, -1, &mock, &MockFunction6::ClassVoidFunction6, _SC("ClassVoidFunction6")));
  EXPECT_TRUE(sqb::Bind::BindSingletonFunction<MockFunction6>(m_vm, 1, &mock, &MockFunction6::ConstClassVoidFunction6, _SC("ConstClassVoidFunction6")));
  EXPECT_SQ_SUCCEEDED(m_vm, sq_rawset(m_vm, -3));

  EXPECT_TRUE(sqb::Bind::BindVariable(m_vm, -1, &invalidParameter, _SC("invalidParameter")));
  EXPECT_TRUE(sqb::Bind::BindVariable(m_vm, -1, &parameter0, _SC("parameter0")));
  EXPECT_TRUE(sqb::Bind::BindVariable(m_vm, -1, &parameter1, _SC("parameter1")));
  EXPECT_TRUE(sqb::Bind::BindVariable(m_vm, -1, &parameter2, _SC("parameter2")));
  EXPECT_TRUE(sqb::Bind::BindVariable(m_vm, -1, &parameter3, _SC("parameter3")));
  EXPECT_TRUE(sqb::Bind::BindVariable(m_vm, -1, &parameter4, _SC("parameter4")));
  EXPECT_TRUE(sqb::Bind::BindVariable(m_vm, -1, &parameter5, _SC("parameter5")));
  sq_poptop(m_vm);

  CompileAndSucceedCall("Mock.ClassVoidFunction6(parameter0, parameter1, parameter2, parameter3, parameter4, parameter5)");
  CompileAndSucceedCall("ConstClassVoidFunction6(parameter0, parameter1, parameter2, parameter3, parameter4, parameter5)");

  CompileAndFailCall("Mock.ClassVoidFunction6(invalidParameter, parameter1, parameter2, parameter3, parameter4, parameter5)");
  CheckErrorString("parameter 1 has an invalid type 'OtherBoundClass' ; expected: 'BoundClass'");
  CompileAndFailCall("ConstClassVoidFunction6(invalidParameter, parameter1, parameter2, parameter3, parameter4, parameter5)");
  CheckErrorString("parameter 1 has an invalid type 'OtherBoundClass' ; expected: 'BoundClass'");

  CompileAndFailCall("Mock.ClassVoidFunction6(parameter0, invalidParameter, parameter2, parameter3, parameter4, parameter5)");
  CheckErrorString("parameter 2 has an invalid type 'OtherBoundClass' ; expected: 'BoundClass'");
  CompileAndFailCall("ConstClassVoidFunction6(parameter0, invalidParameter, parameter2, parameter3, parameter4, parameter5)");
  CheckErrorString("parameter 2 has an invalid type 'OtherBoundClass' ; expected: 'BoundClass'");

  CompileAndFailCall("Mock.ClassVoidFunction6(parameter0, parameter1, invalidParameter, parameter3, parameter4, parameter5)");
  CheckErrorString("parameter 3 has an invalid type 'OtherBoundClass' ; expected: 'BoundClass'");
  CompileAndFailCall("ConstClassVoidFunction6(parameter0, parameter1, invalidParameter, parameter3, parameter4, parameter5)");
  CheckErrorString("parameter 3 has an invalid type 'OtherBoundClass' ; expected: 'BoundClass'");

  CompileAndFailCall("Mock.ClassVoidFunction6(parameter0, parameter1, parameter2, invalidParameter, parameter4, parameter5)");
  CheckErrorString("parameter 4 has an invalid type 'OtherBoundClass' ; expected: 'BoundClass'");
  CompileAndFailCall("ConstClassVoidFunction6(parameter0, parameter1, parameter2, invalidParameter, parameter4, parameter5)");
  CheckErrorString("parameter 4 has an invalid type 'OtherBoundClass' ; expected: 'BoundClass'");

  CompileAndFailCall("Mock.ClassVoidFunction6(parameter0, parameter1, parameter2, parameter3, invalidParameter, parameter5)");
  CheckErrorString("parameter 5 has an invalid type 'OtherBoundClass' ; expected: 'BoundClass'");
  CompileAndFailCall("ConstClassVoidFunction6(parameter0, parameter1, parameter2, parameter3, invalidParameter, parameter5)");
  CheckErrorString("parameter 5 has an invalid type 'OtherBoundClass' ; expected: 'BoundClass'");

  CompileAndFailCall("Mock.ClassVoidFunction6(parameter0, parameter1, parameter2, parameter3, parameter4, invalidParameter)");
  CheckErrorString("parameter 6 has an invalid type 'OtherBoundClass' ; expected: 'BoundClass'");
  CompileAndFailCall("ConstClassVoidFunction6(parameter0, parameter1, parameter2, parameter3, parameter4, invalidParameter)");
  CheckErrorString("parameter 6 has an invalid type 'OtherBoundClass' ; expected: 'BoundClass'");
}

//----------------------------------------------------------------------------------------------------------------------
// Test6Parameters
//----------------------------------------------------------------------------------------------------------------------
TEST_F(BindFunctionTest, Test6Parameters)
{
  ::testing::StrictMock<MockFunction6> mock;
  MockFunction6::m_instance = &mock;

  sq_pushroottable(m_vm);
  sqb::Bind::BindClass<BoundClass, sqb::NoBaseClass>(m_vm, -1, _SC("BoundClass"));
  sqb::Bind::BindClass<OtherBoundClass, sqb::NoBaseClass>(m_vm, -1, _SC("OtherBoundClass"));
  sq_poptop(m_vm);

  OtherBoundClass invalidParameter;
  BoundClass parameter0(0);
  BoundClass parameter1(1);
  BoundClass parameter2(2);
  BoundClass parameter3(3);
  BoundClass parameter4(4);
  BoundClass parameter5(5);

  BoundClass expected_result(0xffffffff);
  EXPECT_CALL(mock, ClassFunction6(parameter0, parameter1, parameter2, parameter3, parameter4, parameter5))
    .Times(2)
    .WillRepeatedly(::testing::Return(expected_result));

  // bind the objects required for calling the function
  //
  sq_pushroottable(m_vm);

  EXPECT_TRUE(sqb::Bind::BindFunction(m_vm, -1, &MockFunction6::Function6, _SC("Function6")));

  sq_pushstring(m_vm, _SC("Mock"), -1);
  EXPECT_SQ_SUCCEEDED(m_vm, sq_newclass(m_vm, SQFalse));
  EXPECT_TRUE(sqb::Bind::BindFunction(m_vm, 3, &MockFunction6::Function6, _SC("Function6")));
  EXPECT_SQ_SUCCEEDED(m_vm, sq_rawset(m_vm, -3));

  EXPECT_TRUE(sqb::Bind::BindVariable(m_vm, -1, &invalidParameter, _SC("invalidParameter")));
  EXPECT_TRUE(sqb::Bind::BindVariable(m_vm, -1, &parameter0, _SC("parameter0")));
  EXPECT_TRUE(sqb::Bind::BindVariable(m_vm, -1, &parameter1, _SC("parameter1")));
  EXPECT_TRUE(sqb::Bind::BindVariable(m_vm, -1, &parameter2, _SC("parameter2")));
  EXPECT_TRUE(sqb::Bind::BindVariable(m_vm, -1, &parameter3, _SC("parameter3")));
  EXPECT_TRUE(sqb::Bind::BindVariable(m_vm, -1, &parameter4, _SC("parameter4")));
  EXPECT_TRUE(sqb::Bind::BindVariable(m_vm, -1, &parameter5, _SC("parameter5")));
  sq_poptop(m_vm);

  BoundClass actual_result = CompileAndCallReturnResult<BoundClass>("return Function6(parameter0, parameter1, parameter2, parameter3, parameter4, parameter5)");
  EXPECT_EQ(expected_result, actual_result);
  actual_result = CompileAndCallReturnResult<BoundClass>("return Mock.Function6(parameter0, parameter1, parameter2, parameter3, parameter4, parameter5)");
  EXPECT_EQ(expected_result, actual_result);

  CompileAndFailCall("Function6(invalidParameter, parameter1, parameter2, parameter3, parameter4, parameter5)");
  CheckErrorString("parameter 1 has an invalid type 'OtherBoundClass' ; expected: 'BoundClass'");

  CompileAndFailCall("Function6(parameter0, invalidParameter, parameter2, parameter3, parameter4, parameter5)");
  CheckErrorString("parameter 2 has an invalid type 'OtherBoundClass' ; expected: 'BoundClass'");

  CompileAndFailCall("Function6(parameter0, parameter1, invalidParameter, parameter3, parameter4, parameter5)");
  CheckErrorString("parameter 3 has an invalid type 'OtherBoundClass' ; expected: 'BoundClass'");

  CompileAndFailCall("Function6(parameter0, parameter1, parameter2, invalidParameter, parameter4, parameter5)");
  CheckErrorString("parameter 4 has an invalid type 'OtherBoundClass' ; expected: 'BoundClass'");

  CompileAndFailCall("Function6(parameter0, parameter1, parameter2, parameter3, invalidParameter, parameter5)");
  CheckErrorString("parameter 5 has an invalid type 'OtherBoundClass' ; expected: 'BoundClass'");

  CompileAndFailCall("Function6(parameter0, parameter1, parameter2, parameter3, parameter4, invalidParameter)");
  CheckErrorString("parameter 6 has an invalid type 'OtherBoundClass' ; expected: 'BoundClass'");
}

//----------------------------------------------------------------------------------------------------------------------
// Test6Parameters
//----------------------------------------------------------------------------------------------------------------------
TEST_F(BindClassFunctionTest, Test6Parameters)
{
  ::testing::StrictMock<MockFunction6> mock;
  MockFunction6::m_instance = &mock;

  sq_pushroottable(m_vm);
  sqb::Bind::BindClass<BoundClass, sqb::NoBaseClass>(m_vm, -1, _SC("BoundClass"));
  sqb::Bind::BindClass<OtherBoundClass, sqb::NoBaseClass>(m_vm, -1, _SC("OtherBoundClass"));
  sq_poptop(m_vm);

  OtherBoundClass invalidParameter;
  BoundClass parameter0(0);
  BoundClass parameter1(1);
  BoundClass parameter2(2);
  BoundClass parameter3(3);
  BoundClass parameter4(4);
  BoundClass parameter5(5);

  BoundClass expected_result(0xffffffff);
  EXPECT_CALL(mock, ClassFunction6(parameter0, parameter1, parameter2, parameter3, parameter4, parameter5))
    .WillOnce(::testing::Return(expected_result));
  EXPECT_CALL(mock, ConstClassFunction6(parameter0, parameter1, parameter2, parameter3, parameter4, parameter5))
    .WillOnce(::testing::Return(expected_result));

  // bind the objects required for calling the function
  //
  sq_pushroottable(m_vm);

  // bind the mock class
  //
  EXPECT_SQ_SUCCEEDED(m_vm, sq_newclass(m_vm, SQFalse));
  EXPECT_SQ_SUCCEEDED(m_vm, sq_settypetag(m_vm, -1, sqb::ClassTypeTag<MockFunction6>::Get()));
  HSQOBJECT class_object;
  sq_getstackobj(m_vm, -1, &class_object);
  sqb::ClassTypeTag<MockFunction6>::Get()->SetClassObject(m_vm, class_object);
  EXPECT_TRUE(sqb::Bind::BindClassFunction<MockFunction6>(m_vm, -1, &MockFunction6::ClassFunction6, _SC("ClassFunction6")));
  EXPECT_TRUE(sqb::Bind::BindClassFunction<MockFunction6>(m_vm, 2, &MockFunction6::ConstClassFunction6, _SC("ConstClassFunction6")));
  sq_poptop(m_vm);

  EXPECT_TRUE(sqb::Bind::BindVariable(m_vm, -1, static_cast<MockFunction6 *>(&mock), _SC("mock")));

  EXPECT_TRUE(sqb::Bind::BindVariable(m_vm, -1, &invalidParameter, _SC("invalidParameter")));
  EXPECT_TRUE(sqb::Bind::BindVariable(m_vm, -1, &parameter0, _SC("parameter0")));
  EXPECT_TRUE(sqb::Bind::BindVariable(m_vm, -1, &parameter1, _SC("parameter1")));
  EXPECT_TRUE(sqb::Bind::BindVariable(m_vm, -1, &parameter2, _SC("parameter2")));
  EXPECT_TRUE(sqb::Bind::BindVariable(m_vm, -1, &parameter3, _SC("parameter3")));
  EXPECT_TRUE(sqb::Bind::BindVariable(m_vm, -1, &parameter4, _SC("parameter4")));
  EXPECT_TRUE(sqb::Bind::BindVariable(m_vm, -1, &parameter5, _SC("parameter5")));
  sq_poptop(m_vm);

  BoundClass actual_result = CompileAndCallReturnResult<BoundClass>("return mock.ClassFunction6(parameter0, parameter1, parameter2, parameter3, parameter4, parameter5)");
  EXPECT_EQ(expected_result, actual_result);
  actual_result = CompileAndCallReturnResult<BoundClass>("return mock.ConstClassFunction6(parameter0, parameter1, parameter2, parameter3, parameter4, parameter5)");
  EXPECT_EQ(expected_result, actual_result);

  CompileAndFailCall("mock.ClassFunction6(invalidParameter, parameter1, parameter2, parameter3, parameter4, parameter5)");
  CheckErrorString("parameter 1 has an invalid type 'OtherBoundClass' ; expected: 'BoundClass'");
  CompileAndFailCall("mock.ConstClassFunction6(invalidParameter, parameter1, parameter2, parameter3, parameter4, parameter5)");
  CheckErrorString("parameter 1 has an invalid type 'OtherBoundClass' ; expected: 'BoundClass'");

  CompileAndFailCall("mock.ClassFunction6(parameter0, invalidParameter, parameter2, parameter3, parameter4, parameter5)");
  CheckErrorString("parameter 2 has an invalid type 'OtherBoundClass' ; expected: 'BoundClass'");
  CompileAndFailCall("mock.ConstClassFunction6(parameter0, invalidParameter, parameter2, parameter3, parameter4, parameter5)");
  CheckErrorString("parameter 2 has an invalid type 'OtherBoundClass' ; expected: 'BoundClass'");

  CompileAndFailCall("mock.ClassFunction6(parameter0, parameter1, invalidParameter, parameter3, parameter4, parameter5)");
  CheckErrorString("parameter 3 has an invalid type 'OtherBoundClass' ; expected: 'BoundClass'");
  CompileAndFailCall("mock.ConstClassFunction6(parameter0, parameter1, invalidParameter, parameter3, parameter4, parameter5)");
  CheckErrorString("parameter 3 has an invalid type 'OtherBoundClass' ; expected: 'BoundClass'");

  CompileAndFailCall("mock.ClassFunction6(parameter0, parameter1, parameter2, invalidParameter, parameter4, parameter5)");
  CheckErrorString("parameter 4 has an invalid type 'OtherBoundClass' ; expected: 'BoundClass'");
  CompileAndFailCall("mock.ConstClassFunction6(parameter0, parameter1, parameter2, invalidParameter, parameter4, parameter5)");
  CheckErrorString("parameter 4 has an invalid type 'OtherBoundClass' ; expected: 'BoundClass'");

  CompileAndFailCall("mock.ClassFunction6(parameter0, parameter1, parameter2, parameter3, invalidParameter, parameter5)");
  CheckErrorString("parameter 5 has an invalid type 'OtherBoundClass' ; expected: 'BoundClass'");
  CompileAndFailCall("mock.ConstClassFunction6(parameter0, parameter1, parameter2, parameter3, invalidParameter, parameter5)");
  CheckErrorString("parameter 5 has an invalid type 'OtherBoundClass' ; expected: 'BoundClass'");

  CompileAndFailCall("mock.ClassFunction6(parameter0, parameter1, parameter2, parameter3, parameter4, invalidParameter)");
  CheckErrorString("parameter 6 has an invalid type 'OtherBoundClass' ; expected: 'BoundClass'");
  CompileAndFailCall("mock.ConstClassFunction6(parameter0, parameter1, parameter2, parameter3, parameter4, invalidParameter)");
  CheckErrorString("parameter 6 has an invalid type 'OtherBoundClass' ; expected: 'BoundClass'");
}

//----------------------------------------------------------------------------------------------------------------------
// Test6Parameters
//----------------------------------------------------------------------------------------------------------------------
TEST_F(BindSingletonFunctionTest, Test6Parameters)
{
  ::testing::StrictMock<MockFunction6> mock;
  MockFunction6::m_instance = &mock;

  sq_pushroottable(m_vm);
  sqb::Bind::BindClass<BoundClass, sqb::NoBaseClass>(m_vm, -1, _SC("BoundClass"));
  sqb::Bind::BindClass<OtherBoundClass, sqb::NoBaseClass>(m_vm, -1, _SC("OtherBoundClass"));
  sq_poptop(m_vm);

  OtherBoundClass invalidParameter;
  BoundClass parameter0(0);
  BoundClass parameter1(1);
  BoundClass parameter2(2);
  BoundClass parameter3(3);
  BoundClass parameter4(4);
  BoundClass parameter5(5);

  BoundClass expected_result(0xffffffff);
  EXPECT_CALL(mock, ClassFunction6(parameter0, parameter1, parameter2, parameter3, parameter4, parameter5))
    .WillOnce(::testing::Return(expected_result));
  EXPECT_CALL(mock, ConstClassFunction6(parameter0, parameter1, parameter2, parameter3, parameter4, parameter5))
    .WillOnce(::testing::Return(expected_result));

  // bind the objects required for calling the function
  //
  sq_pushroottable(m_vm);

  // bind the mock class
  //
  sq_pushstring(m_vm, _SC("Mock"), -1);
  EXPECT_SQ_SUCCEEDED(m_vm, sq_newclass(m_vm, SQFalse));
  EXPECT_TRUE(sqb::Bind::BindSingletonFunction<MockFunction6>(m_vm, -1, &mock, &MockFunction6::ClassFunction6, _SC("ClassFunction6")));
  EXPECT_TRUE(sqb::Bind::BindSingletonFunction<MockFunction6>(m_vm, 1, &mock, &MockFunction6::ConstClassFunction6, _SC("ConstClassFunction6")));
  EXPECT_SQ_SUCCEEDED(m_vm, sq_rawset(m_vm, -3));

  EXPECT_TRUE(sqb::Bind::BindVariable(m_vm, -1, &invalidParameter, _SC("invalidParameter")));
  EXPECT_TRUE(sqb::Bind::BindVariable(m_vm, -1, &parameter0, _SC("parameter0")));
  EXPECT_TRUE(sqb::Bind::BindVariable(m_vm, -1, &parameter1, _SC("parameter1")));
  EXPECT_TRUE(sqb::Bind::BindVariable(m_vm, -1, &parameter2, _SC("parameter2")));
  EXPECT_TRUE(sqb::Bind::BindVariable(m_vm, -1, &parameter3, _SC("parameter3")));
  EXPECT_TRUE(sqb::Bind::BindVariable(m_vm, -1, &parameter4, _SC("parameter4")));
  EXPECT_TRUE(sqb::Bind::BindVariable(m_vm, -1, &parameter5, _SC("parameter5")));
  sq_poptop(m_vm);

  BoundClass actual_result = CompileAndCallReturnResult<BoundClass>("return Mock.ClassFunction6(parameter0, parameter1, parameter2, parameter3, parameter4, parameter5)");
  EXPECT_EQ(expected_result, actual_result);
  actual_result = CompileAndCallReturnResult<BoundClass>("return ConstClassFunction6(parameter0, parameter1, parameter2, parameter3, parameter4, parameter5)");
  EXPECT_EQ(expected_result, actual_result);

  CompileAndFailCall("Mock.ClassFunction6(invalidParameter, parameter1, parameter2, parameter3, parameter4, parameter5)");
  CheckErrorString("parameter 1 has an invalid type 'OtherBoundClass' ; expected: 'BoundClass'");
  CompileAndFailCall("ConstClassFunction6(invalidParameter, parameter1, parameter2, parameter3, parameter4, parameter5)");
  CheckErrorString("parameter 1 has an invalid type 'OtherBoundClass' ; expected: 'BoundClass'");

  CompileAndFailCall("Mock.ClassFunction6(parameter0, invalidParameter, parameter2, parameter3, parameter4, parameter5)");
  CheckErrorString("parameter 2 has an invalid type 'OtherBoundClass' ; expected: 'BoundClass'");
  CompileAndFailCall("ConstClassFunction6(parameter0, invalidParameter, parameter2, parameter3, parameter4, parameter5)");
  CheckErrorString("parameter 2 has an invalid type 'OtherBoundClass' ; expected: 'BoundClass'");

  CompileAndFailCall("Mock.ClassFunction6(parameter0, parameter1, invalidParameter, parameter3, parameter4, parameter5)");
  CheckErrorString("parameter 3 has an invalid type 'OtherBoundClass' ; expected: 'BoundClass'");
  CompileAndFailCall("ConstClassFunction6(parameter0, parameter1, invalidParameter, parameter3, parameter4, parameter5)");
  CheckErrorString("parameter 3 has an invalid type 'OtherBoundClass' ; expected: 'BoundClass'");

  CompileAndFailCall("Mock.ClassFunction6(parameter0, parameter1, parameter2, invalidParameter, parameter4, parameter5)");
  CheckErrorString("parameter 4 has an invalid type 'OtherBoundClass' ; expected: 'BoundClass'");
  CompileAndFailCall("ConstClassFunction6(parameter0, parameter1, parameter2, invalidParameter, parameter4, parameter5)");
  CheckErrorString("parameter 4 has an invalid type 'OtherBoundClass' ; expected: 'BoundClass'");

  CompileAndFailCall("Mock.ClassFunction6(parameter0, parameter1, parameter2, parameter3, invalidParameter, parameter5)");
  CheckErrorString("parameter 5 has an invalid type 'OtherBoundClass' ; expected: 'BoundClass'");
  CompileAndFailCall("ConstClassFunction6(parameter0, parameter1, parameter2, parameter3, invalidParameter, parameter5)");
  CheckErrorString("parameter 5 has an invalid type 'OtherBoundClass' ; expected: 'BoundClass'");

  CompileAndFailCall("Mock.ClassFunction6(parameter0, parameter1, parameter2, parameter3, parameter4, invalidParameter)");
  CheckErrorString("parameter 6 has an invalid type 'OtherBoundClass' ; expected: 'BoundClass'");
  CompileAndFailCall("ConstClassFunction6(parameter0, parameter1, parameter2, parameter3, parameter4, invalidParameter)");
  CheckErrorString("parameter 6 has an invalid type 'OtherBoundClass' ; expected: 'BoundClass'");
}

//----------------------------------------------------------------------------------------------------------------------
// Test6ParametersReturnInvalid
//----------------------------------------------------------------------------------------------------------------------
TEST_F(BindFunctionTest, Test6ParametersReturnInvalid)
{
  ::testing::StrictMock<MockFunction6> mock;
  MockFunction6::m_instance = &mock;

  sq_pushroottable(m_vm);
  sqb::Bind::BindClass<BoundClass, sqb::NoBaseClass>(m_vm, -1, _SC("BoundClass"));
  sqb::Bind::BindClass<OtherBoundClass, sqb::NoBaseClass>(m_vm, -1, _SC("OtherBoundClass"));
  sq_poptop(m_vm);

  BoundClass parameter0(0);
  BoundClass parameter1(1);
  BoundClass parameter2(2);
  BoundClass parameter3(3);
  BoundClass parameter4(4);
  BoundClass parameter5(5);

  InvalidStackUtilsClass expected_result;
  EXPECT_CALL(mock, ClassInvalidFunction6(parameter0, parameter1, parameter2, parameter3, parameter4, parameter5))
    .Times(2)
    .WillRepeatedly(::testing::Return(expected_result));

  // bind the objects required for calling the function
  //
  sq_pushroottable(m_vm);

  EXPECT_TRUE(sqb::Bind::BindFunction(m_vm, -1, &MockFunction6::InvalidFunction6, _SC("InvalidFunction6")));

  sq_pushstring(m_vm, _SC("Mock"), -1);
  EXPECT_SQ_SUCCEEDED(m_vm, sq_newclass(m_vm, SQFalse));
  EXPECT_TRUE(sqb::Bind::BindFunction(m_vm, 3, &MockFunction6::InvalidFunction6, _SC("InvalidFunction6")));
  EXPECT_SQ_SUCCEEDED(m_vm, sq_rawset(m_vm, -3));

  EXPECT_TRUE(sqb::Bind::BindVariable(m_vm, -1, &parameter0, _SC("parameter0")));
  EXPECT_TRUE(sqb::Bind::BindVariable(m_vm, -1, &parameter1, _SC("parameter1")));
  EXPECT_TRUE(sqb::Bind::BindVariable(m_vm, -1, &parameter2, _SC("parameter2")));
  EXPECT_TRUE(sqb::Bind::BindVariable(m_vm, -1, &parameter3, _SC("parameter3")));
  EXPECT_TRUE(sqb::Bind::BindVariable(m_vm, -1, &parameter4, _SC("parameter4")));
  EXPECT_TRUE(sqb::Bind::BindVariable(m_vm, -1, &parameter5, _SC("parameter5")));
  sq_poptop(m_vm);

  CompileAndFailCall("InvalidFunction6(parameter0, parameter1, parameter2, parameter3, parameter4, parameter5)");
  CheckErrorString("error returning object of type 'InvalidStackUtilsClass'");
  CompileAndFailCall("Mock.InvalidFunction6(parameter0, parameter1, parameter2, parameter3, parameter4, parameter5)");
  CheckErrorString("error returning object of type 'InvalidStackUtilsClass'");
}

//----------------------------------------------------------------------------------------------------------------------
// Test6ParametersReturnInvalid
//----------------------------------------------------------------------------------------------------------------------
TEST_F(BindClassFunctionTest, Test6ParametersReturnInvalid)
{
  ::testing::StrictMock<MockFunction6> mock;
  MockFunction6::m_instance = &mock;

  sq_pushroottable(m_vm);
  sqb::Bind::BindClass<BoundClass, sqb::NoBaseClass>(m_vm, -1, _SC("BoundClass"));
  sqb::Bind::BindClass<OtherBoundClass, sqb::NoBaseClass>(m_vm, -1, _SC("OtherBoundClass"));
  sq_poptop(m_vm);

  BoundClass parameter0(0);
  BoundClass parameter1(1);
  BoundClass parameter2(2);
  BoundClass parameter3(3);
  BoundClass parameter4(4);
  BoundClass parameter5(5);

  InvalidStackUtilsClass expected_result;
  EXPECT_CALL(mock, ClassInvalidFunction6(parameter0, parameter1, parameter2, parameter3, parameter4, parameter5))
    .WillOnce(::testing::Return(expected_result));
  EXPECT_CALL(mock, ConstClassInvalidFunction6(parameter0, parameter1, parameter2, parameter3, parameter4, parameter5))
    .WillOnce(::testing::Return(expected_result));

  // bind the objects required for calling the function
  //
  sq_pushroottable(m_vm);

  // bind the mock class
  //
  EXPECT_SQ_SUCCEEDED(m_vm, sq_newclass(m_vm, SQFalse));
  EXPECT_SQ_SUCCEEDED(m_vm, sq_settypetag(m_vm, -1, sqb::ClassTypeTag<MockFunction6>::Get()));
  HSQOBJECT class_object;
  sq_getstackobj(m_vm, -1, &class_object);
  sqb::ClassTypeTag<MockFunction6>::Get()->SetClassObject(m_vm, class_object);
  EXPECT_TRUE(sqb::Bind::BindClassFunction<MockFunction6>(m_vm, -1, &MockFunction6::ClassInvalidFunction6, _SC("ClassInvalidFunction6")));
  EXPECT_TRUE(sqb::Bind::BindClassFunction<MockFunction6>(m_vm, 2, &MockFunction6::ConstClassInvalidFunction6, _SC("ConstClassInvalidFunction6")));
  sq_poptop(m_vm);

  EXPECT_TRUE(sqb::Bind::BindVariable(m_vm, -1, static_cast<MockFunction6 *>(&mock), _SC("mock")));

  EXPECT_TRUE(sqb::Bind::BindVariable(m_vm, -1, &parameter0, _SC("parameter0")));
  EXPECT_TRUE(sqb::Bind::BindVariable(m_vm, -1, &parameter1, _SC("parameter1")));
  EXPECT_TRUE(sqb::Bind::BindVariable(m_vm, -1, &parameter2, _SC("parameter2")));
  EXPECT_TRUE(sqb::Bind::BindVariable(m_vm, -1, &parameter3, _SC("parameter3")));
  EXPECT_TRUE(sqb::Bind::BindVariable(m_vm, -1, &parameter4, _SC("parameter4")));
  EXPECT_TRUE(sqb::Bind::BindVariable(m_vm, -1, &parameter5, _SC("parameter5")));
  sq_poptop(m_vm);

  CompileAndFailCall("mock.ClassInvalidFunction6(parameter0, parameter1, parameter2, parameter3, parameter4, parameter5)");
  CheckErrorString("error returning object of type 'InvalidStackUtilsClass'");
  CompileAndFailCall("mock.ConstClassInvalidFunction6(parameter0, parameter1, parameter2, parameter3, parameter4, parameter5)");
  CheckErrorString("error returning object of type 'InvalidStackUtilsClass'");
}

//----------------------------------------------------------------------------------------------------------------------
// Test6ParametersReturnInvalid
//----------------------------------------------------------------------------------------------------------------------
TEST_F(BindSingletonFunctionTest, Test6ParametersReturnInvalid)
{
  ::testing::StrictMock<MockFunction6> mock;
  MockFunction6::m_instance = &mock;

  sq_pushroottable(m_vm);
  sqb::Bind::BindClass<BoundClass, sqb::NoBaseClass>(m_vm, -1, _SC("BoundClass"));
  sqb::Bind::BindClass<OtherBoundClass, sqb::NoBaseClass>(m_vm, -1, _SC("OtherBoundClass"));
  sq_poptop(m_vm);

  BoundClass parameter0(0);
  BoundClass parameter1(1);
  BoundClass parameter2(2);
  BoundClass parameter3(3);
  BoundClass parameter4(4);
  BoundClass parameter5(5);

  InvalidStackUtilsClass expected_result;
  EXPECT_CALL(mock, ClassInvalidFunction6(parameter0, parameter1, parameter2, parameter3, parameter4, parameter5))
    .WillOnce(::testing::Return(expected_result));
  EXPECT_CALL(mock, ConstClassInvalidFunction6(parameter0, parameter1, parameter2, parameter3, parameter4, parameter5))
    .WillOnce(::testing::Return(expected_result));

  // bind the objects required for calling the function
  //
  sq_pushroottable(m_vm);

  // bind the mock class
  //
  sq_pushstring(m_vm, _SC("Mock"), -1);
  EXPECT_SQ_SUCCEEDED(m_vm, sq_newclass(m_vm, SQFalse));
  EXPECT_TRUE(sqb::Bind::BindSingletonFunction<MockFunction6>(m_vm, -1, &mock, &MockFunction6::ClassInvalidFunction6, _SC("ClassInvalidFunction6")));
  EXPECT_TRUE(sqb::Bind::BindSingletonFunction<MockFunction6>(m_vm, 1, &mock, &MockFunction6::ConstClassInvalidFunction6, _SC("ConstClassInvalidFunction6")));
  EXPECT_SQ_SUCCEEDED(m_vm, sq_rawset(m_vm, -3));

  EXPECT_TRUE(sqb::Bind::BindVariable(m_vm, -1, &parameter0, _SC("parameter0")));
  EXPECT_TRUE(sqb::Bind::BindVariable(m_vm, -1, &parameter1, _SC("parameter1")));
  EXPECT_TRUE(sqb::Bind::BindVariable(m_vm, -1, &parameter2, _SC("parameter2")));
  EXPECT_TRUE(sqb::Bind::BindVariable(m_vm, -1, &parameter3, _SC("parameter3")));
  EXPECT_TRUE(sqb::Bind::BindVariable(m_vm, -1, &parameter4, _SC("parameter4")));
  EXPECT_TRUE(sqb::Bind::BindVariable(m_vm, -1, &parameter5, _SC("parameter5")));
  sq_poptop(m_vm);

  CompileAndFailCall("Mock.ClassInvalidFunction6(parameter0, parameter1, parameter2, parameter3, parameter4, parameter5)");
  CheckErrorString("error returning object of type 'InvalidStackUtilsClass'");
  CompileAndFailCall("ConstClassInvalidFunction6(parameter0, parameter1, parameter2, parameter3, parameter4, parameter5)");
  CheckErrorString("error returning object of type 'InvalidStackUtilsClass'");
}

} // namespace autogen
